package 网络编程.Text;

import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.net.ServerSocket;
import java.net.Socket;

public class TCPText2 {
    public static void main(String[] args) throws IOException {
        //客户端:多次发送数据
        //服务端:接收多次数据,并打印

        //创建服务器端对象与客户端建立连接
        ServerSocket ss=new ServerSocket(10006);
        //监听客户端连接
        Socket accept = ss.accept();
        //读取数据
        InputStream inputStream = accept.getInputStream();
        InputStreamReader ir=new InputStreamReader(inputStream);
        int a;
        System.out.println("接收到的数据");
        while ((a=ir.read())!=-1){
            System.out.print((char) a);
        }
        //释放资源
        accept.close();
        ss.close();
    }
}
